<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

class CreateRelationBackupsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('relation_backups', function (Blueprint $table) {
            $table->id();
            $table->integer('user_id')->unsigned()->comment('用户id');
            $table->integer('pid')->unsigned()->comment('推荐人id');
            $table->text('parent_all')->comment('关系链');
            $table->integer('level')->unsigned()->comment('代数');
            $table->tinyInteger('type')->default(1)->comment('备份类型，,1微信登陆备份，2关注事件备份，3扫码绑定关系备份，4后台修改关系备份');
            $table->timestamps();
        });

        DB::statement("ALTER TABLE `relation_backups` comment '用户推荐关系备份表，验证左右值知否准备'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('relation_backups');
    }
}
